#include"Processpool.hpp"

void Usage(string proc)
{
    cout << "Usage:" << proc << " process-num" << endl;
}

// 通过命令行传入的参数 创建指定个数的子进程
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        return UsageError;
    }
    int num = stoi(argv[1]); // 将字符串转换为整形

    ProcessPool *pp = new ProcessPool(num, Worker);

    // 1.初始化任务
    pp->InitProcessPool();
    // 2.派发任务
    pp->DispatchTask();
    // 3.退出进程池
    pp->CleanProcessPool();

    // vector<Channel> channels;
    // // 1.初始化任务
    // InitProcessPool(num, channels, Worker);

    // // DebugPrint(channels);

    // // 2.派发任务
    // DispatchTask(channels);

    // // 3.退出进程池
    // CleanProcessPool(channels);

    delete pp;
    return 0;
}